/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.fatecpg.peso;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Calendar;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

/**
 * @author GESSICA
 */
public class PesoMIDlet extends MIDlet implements CommandListener, ItemCommandListener {
    
    private boolean midletPaused = false;
    
    private RecordStore store;
    private void openStore() throws RecordStoreException{
        if(store == null){
            store = RecordStore.openRecordStore("IMC", true);
        }
    }
    private void closeStore() throws Exception{
       if(store == null){
           store.closeRecordStore();
           store = null;
       }        
    }
    private void atualizarLista(){
        list.deleteAll();
        try{
            openStore();
            RecordEnumeration e = store.enumerateRecords(null, null, false);
            while((e.hasNextElement())){
                int id = e.nextRecordId();
                byte[] bytes = store.getRecord(id);
                ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                DataInputStream dis = new DataInputStream(bais);
                String data = dis.readUTF();
                double peso = Double.parseDouble(dis.readUTF());
                double altura = Double.parseDouble(dis.readUTF());
                double imc = (peso/(altura*altura));
                list.append("Data: "+data+"\n IMC: "+ imc +"\n", null);
            }
            closeStore();
        }catch(Exception ex){
            Alert erro = new Alert("Erro");
            erro.setString(ex.getMessage());
            erro.setTimeout(3000);
            getDisplay().setCurrent(erro);
        }
    }
    private void gravar(){
        try{
        String peso = pesoTextField.getString();
        String altura = alturaTextField.getString();
        Calendar data = Calendar.getInstance();
        String date = (data.get(Calendar.DAY_OF_MONTH)+"/"+((data.get(Calendar.MONTH))+1)+"/"+data.get(Calendar.YEAR));
        
        openStore();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        dos.writeUTF(date);
        dos.writeUTF(peso);
        dos.writeUTF(altura);
        byte[] bytes = baos.toByteArray();
        store.addRecord(bytes, 0, bytes.length);
        closeStore();
        
        stringItem.setText("Gravado com sucesso!");
        
    }catch(Exception ex){
        Alert erro = new Alert("Erro");
        erro.setString(ex.getMessage());
        erro.setTimeout(3000);
        getDisplay().setCurrent(erro);
    }
    switchDisplayable(null, getForm());
    }
    
    
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
private Command exitCommand;
private Command novoCommand;
private Command exibirCommand;
private Command cancelarCommand;
private Command gravarCommand;
private Command voltarListaCommand;
private Command voltarCommand1;
private Command gravarItemCommand;
private Command novoItemCommand;
private Command exibirItemCommand;
private Form form;
private ImageItem novoImageItem;
private StringItem stringItem;
private ImageItem exibirImageItem;
private StringItem stringItem1;
private StringItem stringItem2;
private List list;
private Form novoForm;
private TextField pesoTextField;
private TextField alturaTextField;
private ImageItem imageItem;
private StringItem stringItem3;
private StringItem stringItem4;
private Font font1;
private Image image3;
private Image image;
private Image image4;
//</editor-fold>//GEN-END:|fields|0|

    /**
     * The PesoMIDlet constructor.
     */
    public PesoMIDlet() {
    }

//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
/**
 * Initializes the application.
 * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
 */
private void initialize () {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
}//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
/**
 * Performs an action assigned to the Mobile Device - MIDlet Started point.
 */
public void startMIDlet () {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
switchDisplayable (null, getForm ());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
}//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
/**
 * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
 */
public void resumeMIDlet () {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
}//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
/**
 * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
 * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
 * @param nextDisplayable the Displayable to be set
 */
public void switchDisplayable (Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
Display display = getDisplay ();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
if (alert == null) {
display.setCurrent (nextDisplayable);
} else {
display.setCurrent (alert, nextDisplayable);
}//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
}//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
/**
 * Called by a system to indicated that a command has been invoked on a particular displayable.
 * @param command the Command that was invoked
 * @param displayable the Displayable where the command was invoked
 */
public void commandAction (Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
if (displayable == form) {//GEN-BEGIN:|7-commandAction|1|25-preAction
if (command == exibirCommand) {//GEN-END:|7-commandAction|1|25-preAction
 // write pre-action user code here
switchDisplayable (null, getList ());//GEN-LINE:|7-commandAction|2|25-postAction
 atualizarLista();
 
} else if (command == exitCommand) {//GEN-LINE:|7-commandAction|3|19-preAction
                // write pre-action user code here
exitMIDlet ();//GEN-LINE:|7-commandAction|4|19-postAction
                // write post-action user code here
} else if (command == novoCommand) {//GEN-LINE:|7-commandAction|5|23-preAction
       
switchDisplayable (null, getNovoForm ());//GEN-LINE:|7-commandAction|6|23-postAction
    pesoTextField.setString("");
    alturaTextField.setString("");
}//GEN-BEGIN:|7-commandAction|7|28-preAction
} else if (displayable == list) {
if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|7|28-preAction
 // write pre-action user code here
listAction ();//GEN-LINE:|7-commandAction|8|28-postAction
 // write post-action user code here
} else if (command == voltarCommand1) {//GEN-LINE:|7-commandAction|9|47-preAction
 // write pre-action user code here
switchDisplayable (null, getForm ());//GEN-LINE:|7-commandAction|10|47-postAction
 // write post-action user code here
}//GEN-BEGIN:|7-commandAction|11|36-preAction
} else if (displayable == novoForm) {
if (command == cancelarCommand) {//GEN-END:|7-commandAction|11|36-preAction
 // write pre-action user code here
switchDisplayable (null, getForm ());//GEN-LINE:|7-commandAction|12|36-postAction
 // write post-action user code here
} else if (command == gravarCommand) {//GEN-LINE:|7-commandAction|13|38-preAction
 
switchDisplayable (null, getForm ());//GEN-LINE:|7-commandAction|14|38-postAction
    gravar();
}//GEN-BEGIN:|7-commandAction|15|7-postCommandAction
}//GEN-END:|7-commandAction|15|7-postCommandAction
        // write post-action user code here
}//GEN-BEGIN:|7-commandAction|16|
//</editor-fold>//GEN-END:|7-commandAction|16|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
/**
 * Returns an initiliazed instance of exitCommand component.
 * @return the initialized component instance
 */
public Command getExitCommand () {
if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
exitCommand = new Command ("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
}//GEN-BEGIN:|18-getter|2|
return exitCommand;
}
//</editor-fold>//GEN-END:|18-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|14-getter|0|14-preInit
/**
 * Returns an initiliazed instance of form component.
 * @return the initialized component instance
 */
public Form getForm () {
if (form == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
form = new Form ("Hist\u00F3rico IMC", new Item[] { getStringItem (), getNovoImageItem (), getStringItem2 (), getExibirImageItem (), getStringItem1 () });//GEN-BEGIN:|14-getter|1|14-postInit
form.addCommand (getExitCommand ());
form.addCommand (getNovoCommand ());
form.addCommand (getExibirCommand ());
form.setCommandListener (this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
}//GEN-BEGIN:|14-getter|2|
return form;
}
//</editor-fold>//GEN-END:|14-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: novoCommand ">//GEN-BEGIN:|22-getter|0|22-preInit
/**
 * Returns an initiliazed instance of novoCommand component.
 * @return the initialized component instance
 */
public Command getNovoCommand () {
if (novoCommand == null) {//GEN-END:|22-getter|0|22-preInit
 // write pre-init user code here
novoCommand = new Command ("Novo", Command.ITEM, 0);//GEN-LINE:|22-getter|1|22-postInit
 // write post-init user code here
}//GEN-BEGIN:|22-getter|2|
return novoCommand;
}
//</editor-fold>//GEN-END:|22-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exibirCommand ">//GEN-BEGIN:|24-getter|0|24-preInit
/**
 * Returns an initiliazed instance of exibirCommand component.
 * @return the initialized component instance
 */
public Command getExibirCommand () {
if (exibirCommand == null) {//GEN-END:|24-getter|0|24-preInit
 // write pre-init user code here
exibirCommand = new Command ("Exibir", Command.ITEM, 0);//GEN-LINE:|24-getter|1|24-postInit
 // write post-init user code here
}//GEN-BEGIN:|24-getter|2|
return exibirCommand;
}
//</editor-fold>//GEN-END:|24-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancelarCommand ">//GEN-BEGIN:|35-getter|0|35-preInit
/**
 * Returns an initiliazed instance of cancelarCommand component.
 * @return the initialized component instance
 */
public Command getCancelarCommand () {
if (cancelarCommand == null) {//GEN-END:|35-getter|0|35-preInit
 // write pre-init user code here
cancelarCommand = new Command ("Cancelar", Command.CANCEL, 0);//GEN-LINE:|35-getter|1|35-postInit
 // write post-init user code here
}//GEN-BEGIN:|35-getter|2|
return cancelarCommand;
}
//</editor-fold>//GEN-END:|35-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: gravarCommand ">//GEN-BEGIN:|37-getter|0|37-preInit
/**
 * Returns an initiliazed instance of gravarCommand component.
 * @return the initialized component instance
 */
public Command getGravarCommand () {
if (gravarCommand == null) {//GEN-END:|37-getter|0|37-preInit
 // write pre-init user code here
gravarCommand = new Command ("Gravar", Command.ITEM, 0);//GEN-LINE:|37-getter|1|37-postInit
 // write post-init user code here
}//GEN-BEGIN:|37-getter|2|
return gravarCommand;
}
//</editor-fold>//GEN-END:|37-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|26-getter|0|26-preInit
/**
 * Returns an initiliazed instance of list component.
 * @return the initialized component instance
 */
public List getList () {
if (list == null) {//GEN-END:|26-getter|0|26-preInit
 // write pre-init user code here
list = new List ("Hist\u00F3rico IMC", Choice.IMPLICIT);//GEN-BEGIN:|26-getter|1|26-postInit
list.addCommand (getVoltarCommand1 ());
list.setCommandListener (this);//GEN-END:|26-getter|1|26-postInit
 // write post-init user code here
}//GEN-BEGIN:|26-getter|2|
return list;
}
//</editor-fold>//GEN-END:|26-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|26-action|0|26-preAction
/**
 * Performs an action assigned to the selected list element in the list component.
 */
public void listAction () {//GEN-END:|26-action|0|26-preAction
 // enter pre-action user code here
String __selectedString = getList ().getString (getList ().getSelectedIndex ());//GEN-LINE:|26-action|1|26-postAction
 // enter post-action user code here
}//GEN-BEGIN:|26-action|2|
//</editor-fold>//GEN-END:|26-action|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: novoForm ">//GEN-BEGIN:|34-getter|0|34-preInit
/**
 * Returns an initiliazed instance of novoForm component.
 * @return the initialized component instance
 */
public Form getNovoForm () {
if (novoForm == null) {//GEN-END:|34-getter|0|34-preInit
 // write pre-init user code here
novoForm = new Form ("Hist\u00F3rico IMC", new Item[] { getStringItem4 (), getPesoTextField (), getAlturaTextField (), getImageItem (), getStringItem3 () });//GEN-BEGIN:|34-getter|1|34-postInit
novoForm.addCommand (getCancelarCommand ());
novoForm.addCommand (getGravarCommand ());
novoForm.setCommandListener (this);//GEN-END:|34-getter|1|34-postInit
 // write post-init user code here
}//GEN-BEGIN:|34-getter|2|
return novoForm;
}
//</editor-fold>//GEN-END:|34-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoTextField ">//GEN-BEGIN:|41-getter|0|41-preInit
/**
 * Returns an initiliazed instance of pesoTextField component.
 * @return the initialized component instance
 */
public TextField getPesoTextField () {
if (pesoTextField == null) {//GEN-END:|41-getter|0|41-preInit
 // write pre-init user code here
pesoTextField = new TextField ("Peso:", "", 7, TextField.DECIMAL);//GEN-BEGIN:|41-getter|1|41-postInit
pesoTextField.setLayout (ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);//GEN-END:|41-getter|1|41-postInit
 // write post-init user code here
}//GEN-BEGIN:|41-getter|2|
return pesoTextField;
}
//</editor-fold>//GEN-END:|41-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarListaCommand ">//GEN-BEGIN:|43-getter|0|43-preInit
/**
 * Returns an initiliazed instance of voltarListaCommand component.
 * @return the initialized component instance
 */
public Command getVoltarListaCommand () {
if (voltarListaCommand == null) {//GEN-END:|43-getter|0|43-preInit
 // write pre-init user code here
voltarListaCommand = new Command ("Voltar", Command.CANCEL, 0);//GEN-LINE:|43-getter|1|43-postInit
 // write post-init user code here
}//GEN-BEGIN:|43-getter|2|
return voltarListaCommand;
}
//</editor-fold>//GEN-END:|43-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarCommand1 ">//GEN-BEGIN:|46-getter|0|46-preInit
/**
 * Returns an initiliazed instance of voltarCommand1 component.
 * @return the initialized component instance
 */
public Command getVoltarCommand1 () {
if (voltarCommand1 == null) {//GEN-END:|46-getter|0|46-preInit
 // write pre-init user code here
voltarCommand1 = new Command ("Voltar", Command.BACK, 0);//GEN-LINE:|46-getter|1|46-postInit
 // write post-init user code here
}//GEN-BEGIN:|46-getter|2|
return voltarCommand1;
}
//</editor-fold>//GEN-END:|46-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alturaTextField ">//GEN-BEGIN:|50-getter|0|50-preInit
/**
 * Returns an initiliazed instance of alturaTextField component.
 * @return the initialized component instance
 */
public TextField getAlturaTextField () {
if (alturaTextField == null) {//GEN-END:|50-getter|0|50-preInit
 // write pre-init user code here
alturaTextField = new TextField ("Altura:", "", 7, TextField.DECIMAL);//GEN-BEGIN:|50-getter|1|50-postInit
alturaTextField.setLayout (ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER);//GEN-END:|50-getter|1|50-postInit
 // write post-init user code here
}//GEN-BEGIN:|50-getter|2|
return alturaTextField;
}
//</editor-fold>//GEN-END:|50-getter|2|







//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Items ">//GEN-BEGIN:|17-itemCommandAction|0|17-preItemCommandAction
/**
 * Called by a system to indicated that a command has been invoked on a particular item.
 * @param command the Command that was invoked
 * @param displayable the Item where the command was invoked
 */
public void commandAction (Command command, Item item) {//GEN-END:|17-itemCommandAction|0|17-preItemCommandAction
 // write pre-action user code here
if (item == exibirImageItem) {//GEN-BEGIN:|17-itemCommandAction|1|73-preAction
if (command == exibirItemCommand) {//GEN-END:|17-itemCommandAction|1|73-preAction
 
switchDisplayable (null, getList ());//GEN-LINE:|17-itemCommandAction|2|73-postAction
 atualizarLista();
 stringItem.setText("Bem vindo!");
}//GEN-BEGIN:|17-itemCommandAction|3|60-preAction
} else if (item == imageItem) {
if (command == gravarItemCommand) {//GEN-END:|17-itemCommandAction|3|60-preAction
 gravar();
//GEN-LINE:|17-itemCommandAction|4|60-postAction
 // write post-action user code here
}//GEN-BEGIN:|17-itemCommandAction|5|68-preAction
} else if (item == novoImageItem) {
if (command == novoItemCommand) {//GEN-END:|17-itemCommandAction|5|68-preAction
 // write pre-action user code here
switchDisplayable (null, getNovoForm ());//GEN-LINE:|17-itemCommandAction|6|68-postAction
    pesoTextField.setString("");
    alturaTextField.setString("");
    stringItem.setText("Bem vindo!");
}//GEN-BEGIN:|17-itemCommandAction|7|17-postItemCommandAction
}//GEN-END:|17-itemCommandAction|7|17-postItemCommandAction
 // write post-action user code here
}//GEN-BEGIN:|17-itemCommandAction|8|
//</editor-fold>//GEN-END:|17-itemCommandAction|8|


//<editor-fold defaultstate="collapsed" desc=" Generated Getter: gravarItemCommand ">//GEN-BEGIN:|59-getter|0|59-preInit
/**
 * Returns an initiliazed instance of gravarItemCommand component.
 * @return the initialized component instance
 */
public Command getGravarItemCommand () {
if (gravarItemCommand == null) {//GEN-END:|59-getter|0|59-preInit
 // write pre-init user code here
gravarItemCommand = new Command ("gravarItem", Command.ITEM, 0);//GEN-LINE:|59-getter|1|59-postInit
 // write post-init user code here
}//GEN-BEGIN:|59-getter|2|
return gravarItemCommand;
}
//</editor-fold>//GEN-END:|59-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: imageItem ">//GEN-BEGIN:|57-getter|0|57-preInit
/**
 * Returns an initiliazed instance of imageItem component.
 * @return the initialized component instance
 */
public ImageItem getImageItem () {
if (imageItem == null) {//GEN-END:|57-getter|0|57-preInit
 // write pre-init user code here
imageItem = new ImageItem ("", getImage (), ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER, "<Imagem perdida>");//GEN-BEGIN:|57-getter|1|57-postInit
imageItem.addCommand (getGravarItemCommand ());
imageItem.setItemCommandListener (this);
imageItem.setDefaultCommand (getGravarItemCommand ());//GEN-END:|57-getter|1|57-postInit
 // write post-init user code here
}//GEN-BEGIN:|57-getter|2|
return imageItem;
}
//</editor-fold>//GEN-END:|57-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: novoImageItem ">//GEN-BEGIN:|61-getter|0|61-preInit
/**
 * Returns an initiliazed instance of novoImageItem component.
 * @return the initialized component instance
 */
public ImageItem getNovoImageItem () {
if (novoImageItem == null) {//GEN-END:|61-getter|0|61-preInit
 // write pre-init user code here
novoImageItem = new ImageItem ("", getImage4 (), ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER, "<Imagem perdida>");//GEN-BEGIN:|61-getter|1|61-postInit
novoImageItem.addCommand (getNovoItemCommand ());
novoImageItem.setItemCommandListener (this);
novoImageItem.setDefaultCommand (getNovoItemCommand ());
novoImageItem.setPreferredSize (-1, -1);//GEN-END:|61-getter|1|61-postInit
 // write post-init user code here
}//GEN-BEGIN:|61-getter|2|
return novoImageItem;
}
//</editor-fold>//GEN-END:|61-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|62-getter|0|62-preInit
/**
 * Returns an initiliazed instance of stringItem component.
 * @return the initialized component instance
 */
public StringItem getStringItem () {
if (stringItem == null) {//GEN-END:|62-getter|0|62-preInit
 // write pre-init user code here
stringItem = new StringItem ("", "Bem vindo!");//GEN-BEGIN:|62-getter|1|62-postInit
stringItem.setLayout (ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER);
stringItem.setFont (getFont1 ());//GEN-END:|62-getter|1|62-postInit
 // write post-init user code here
}//GEN-BEGIN:|62-getter|2|
return stringItem;
}
//</editor-fold>//GEN-END:|62-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exibirImageItem ">//GEN-BEGIN:|63-getter|0|63-preInit
/**
 * Returns an initiliazed instance of exibirImageItem component.
 * @return the initialized component instance
 */
public ImageItem getExibirImageItem () {
if (exibirImageItem == null) {//GEN-END:|63-getter|0|63-preInit
 // write pre-init user code here
exibirImageItem = new ImageItem ("", getImage3 (), ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2, "<Imagem perdida>", Item.PLAIN);//GEN-BEGIN:|63-getter|1|63-postInit
exibirImageItem.addCommand (getExibirItemCommand ());
exibirImageItem.setItemCommandListener (this);
exibirImageItem.setDefaultCommand (getExibirItemCommand ());//GEN-END:|63-getter|1|63-postInit
 // write post-init user code here
}//GEN-BEGIN:|63-getter|2|
return exibirImageItem;
}
//</editor-fold>//GEN-END:|63-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: novoItemCommand ">//GEN-BEGIN:|67-getter|0|67-preInit
/**
 * Returns an initiliazed instance of novoItemCommand component.
 * @return the initialized component instance
 */
public Command getNovoItemCommand () {
if (novoItemCommand == null) {//GEN-END:|67-getter|0|67-preInit
 // write pre-init user code here
novoItemCommand = new Command ("Item", Command.ITEM, 0);//GEN-LINE:|67-getter|1|67-postInit
 
}//GEN-BEGIN:|67-getter|2|
return novoItemCommand;
}
//</editor-fold>//GEN-END:|67-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: font1 ">//GEN-BEGIN:|71-getter|0|71-preInit
/**
 * Returns an initiliazed instance of font1 component.
 * @return the initialized component instance
 */
public Font getFont1 () {
if (font1 == null) {//GEN-END:|71-getter|0|71-preInit
 // write pre-init user code here
font1 = Font.getFont (Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);//GEN-LINE:|71-getter|1|71-postInit
 // write post-init user code here
}//GEN-BEGIN:|71-getter|2|
return font1;
}
//</editor-fold>//GEN-END:|71-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exibirItemCommand ">//GEN-BEGIN:|72-getter|0|72-preInit
/**
 * Returns an initiliazed instance of exibirItemCommand component.
 * @return the initialized component instance
 */
public Command getExibirItemCommand () {
if (exibirItemCommand == null) {//GEN-END:|72-getter|0|72-preInit
 // write pre-init user code here
exibirItemCommand = new Command ("Item", Command.ITEM, 0);//GEN-LINE:|72-getter|1|72-postInit
 // write post-init user code here
}//GEN-BEGIN:|72-getter|2|
return exibirItemCommand;
}
//</editor-fold>//GEN-END:|72-getter|2|



//<editor-fold defaultstate="collapsed" desc=" Generated Getter: image3 ">//GEN-BEGIN:|75-getter|0|75-preInit
/**
 * Returns an initiliazed instance of image3 component.
 * @return the initialized component instance
 */
public Image getImage3 () {
if (image3 == null) {//GEN-END:|75-getter|0|75-preInit
 // write pre-init user code here
try {//GEN-BEGIN:|75-getter|1|75-@java.io.IOException
image3 = Image.createImage ("/images/lupa.png");
} catch (java.io.IOException e) {//GEN-END:|75-getter|1|75-@java.io.IOException
e.printStackTrace ();
}//GEN-LINE:|75-getter|2|75-postInit
 // write post-init user code here
}//GEN-BEGIN:|75-getter|3|
return image3;
}
//</editor-fold>//GEN-END:|75-getter|3|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: image ">//GEN-BEGIN:|76-getter|0|76-preInit
/**
 * Returns an initiliazed instance of image component.
 * @return the initialized component instance
 */
public Image getImage () {
if (image == null) {//GEN-END:|76-getter|0|76-preInit
 // write pre-init user code here
try {//GEN-BEGIN:|76-getter|1|76-@java.io.IOException
image = Image.createImage ("/images/list.png");
} catch (java.io.IOException e) {//GEN-END:|76-getter|1|76-@java.io.IOException
e.printStackTrace ();
}//GEN-LINE:|76-getter|2|76-postInit
 // write post-init user code here
}//GEN-BEGIN:|76-getter|3|
return image;
}
//</editor-fold>//GEN-END:|76-getter|3|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: image4 ">//GEN-BEGIN:|77-getter|0|77-preInit
/**
 * Returns an initiliazed instance of image4 component.
 * @return the initialized component instance
 */
public Image getImage4 () {
if (image4 == null) {//GEN-END:|77-getter|0|77-preInit
 // write pre-init user code here
try {//GEN-BEGIN:|77-getter|1|77-@java.io.IOException
image4 = Image.createImage ("/images/add.png");
} catch (java.io.IOException e) {//GEN-END:|77-getter|1|77-@java.io.IOException
e.printStackTrace ();
}//GEN-LINE:|77-getter|2|77-postInit
 // write post-init user code here
}//GEN-BEGIN:|77-getter|3|
return image4;
}
//</editor-fold>//GEN-END:|77-getter|3|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem1 ">//GEN-BEGIN:|79-getter|0|79-preInit
/**
 * Returns an initiliazed instance of stringItem1 component.
 * @return the initialized component instance
 */
public StringItem getStringItem1 () {
if (stringItem1 == null) {//GEN-END:|79-getter|0|79-preInit
 // write pre-init user code here
stringItem1 = new StringItem ("", "Hist\u00F3rico");//GEN-BEGIN:|79-getter|1|79-postInit
stringItem1.setLayout (ImageItem.LAYOUT_CENTER);//GEN-END:|79-getter|1|79-postInit
 // write post-init user code here
}//GEN-BEGIN:|79-getter|2|
return stringItem1;
}
//</editor-fold>//GEN-END:|79-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem2 ">//GEN-BEGIN:|80-getter|0|80-preInit
/**
 * Returns an initiliazed instance of stringItem2 component.
 * @return the initialized component instance
 */
public StringItem getStringItem2 () {
if (stringItem2 == null) {//GEN-END:|80-getter|0|80-preInit
 // write pre-init user code here
stringItem2 = new StringItem ("", "Novo Registro");//GEN-LINE:|80-getter|1|80-postInit
 // write post-init user code here
}//GEN-BEGIN:|80-getter|2|
return stringItem2;
}
//</editor-fold>//GEN-END:|80-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem3 ">//GEN-BEGIN:|81-getter|0|81-preInit
/**
 * Returns an initiliazed instance of stringItem3 component.
 * @return the initialized component instance
 */
public StringItem getStringItem3 () {
if (stringItem3 == null) {//GEN-END:|81-getter|0|81-preInit
 // write pre-init user code here
stringItem3 = new StringItem ("", "Gravar");//GEN-BEGIN:|81-getter|1|81-postInit
stringItem3.setLayout (ImageItem.LAYOUT_CENTER);//GEN-END:|81-getter|1|81-postInit
 // write post-init user code here
}//GEN-BEGIN:|81-getter|2|
return stringItem3;
}
//</editor-fold>//GEN-END:|81-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem4 ">//GEN-BEGIN:|83-getter|0|83-preInit
/**
 * Returns an initiliazed instance of stringItem4 component.
 * @return the initialized component instance
 */
public StringItem getStringItem4 () {
if (stringItem4 == null) {//GEN-END:|83-getter|0|83-preInit
 // write pre-init user code here
stringItem4 = new StringItem ("", "Insira os dados");//GEN-BEGIN:|83-getter|1|83-postInit
stringItem4.setLayout (ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER);
stringItem4.setFont (getFont1 ());//GEN-END:|83-getter|1|83-postInit
 // write post-init user code here
}//GEN-BEGIN:|83-getter|2|
return stringItem4;
}
//</editor-fold>//GEN-END:|83-getter|2|



    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
}
